package com.example.tired1.zyfypt_14120200131_syn.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.tired1.zyfypt_14120200131_syn.R;
import com.example.tired1.zyfypt_14120200131_syn.adapter.Articleadapter;
import com.example.tired1.zyfypt_14120200131_syn.bean.ArticleBean;
import com.example.tired1.zyfypt_14120200131_syn.bean.Constant;
import com.example.tired1.zyfypt_14120200131_syn.iface.ArticleListener;
import com.example.tired1.zyfypt_14120200131_syn.model.ArticleModel;

import java.util.List;

import static android.content.Context.MODE_PRIVATE;

/**
 * Created by Neusoft on 2017/4/9.
 */

public class Fragment1 extends Fragment implements ArticleListener {
    private  TextView tvinfo;
    private View view=null;
    private Context context;
    private  RecyclerView recyclerView;
    List<ArticleBean> list;
    Articleadapter articleadapter;
    RecyclerView.LayoutManager layoutManager;
    SharedPreferences preferences;
    String sessionId;
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        context = getActivity();
        //动态加载Fragment1的布局文件
        view = inflater.inflate(R.layout.fragment1, container, false);
        //获取布局上的控件，注意通过view获取
        //返回动态生成的view
        View view =inflater.
                inflate(R.layout.fragment1, container, false);

        preferences=context.getSharedPreferences(Constant.PREM_NAME,MODE_PRIVATE);
        sessionId=preferences.getString("sessionId","");

        recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview_article);
        articleadapter = new Articleadapter(context, list);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(articleadapter);

        ArticleModel articleModel = new ArticleModel();
        articleModel.getResultList("article", 2, "dqkq2nn6veir6ua2e0f7etlal7",  this);



        return view;
    }


    @Override
    public void onResponse(List<ArticleBean> beanList) {

    }

    @Override
    public void onFail(String msg) {

    }
}
